@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Throwable.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public APIError allUnknownException(Throwable t) {
        return APIError.build(t.getMessage());
    }

    @ExceptionHandler(EntityAlreadyExistsException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public APIError entityAlreadyExistsException(
        EntityAlreadyExistsException e) {
        return APIError.build(e.getMessage());
    }
    // ...
}
